use strict;
use warnings;

package JasPerl::JSTL::Core::LoopTagStatus;

use JasPerl::Util::Number;

sub new {
    my ($class, $tag) = @_;
    bless \$tag, $class;
}

sub get_current {
    return ${$_[0]}->get_current();
}

sub get_count {
    return JasPerl::Util::Number->new(${$_[0]}->{count});
}

sub get_index {
    return JasPerl::Util::Number->new(${$_[0]}->{index});
}

sub get_begin {
    my $tag = ${$_[0]};
    return unless defined $tag->{begin};
    return JasPerl::Util::Number->new($tag->{begin});
}

sub get_end {
    my $tag = ${$_[0]};
    return unless defined $tag->{end};
    return JasPerl::Util::Number->new($tag->{end});
}

sub get_step {
    my $tag = ${$_[0]};
    return unless defined $tag->{step};
    return JasPerl::Util::Number->new($tag->{step});
}

sub is_first {
    return ${$_[0]}->{index} == (${$_[0]}->{begin} || 0);
}

sub is_last {
    return ${$_[0]}->{last};
}

1;
